﻿-- =========================================================================================================
-- Author:		MICHAEL RITACCO
-- Copyright:	2010 MEKHANO GROUP LLC
-- Version:		10/03/2010 1.0
-- =========================================================================================================
CREATE PROCEDURE [flcr].[api_supplier_sel_lov]
@SUPPLIER_ID INT
,@ACTIVE_FLG BIT = NULL
,@BUILTIN BIT = NULL
,@SUPPLIER_TYPE INT = NULL
,@DOMAIN_ID INT = NULL

AS
BEGIN TRY
  
	SELECT	A.[SUPPLIER_ID]
			,A.[SUPPLIER_NAME] 
			,A.[SUPPLIER_SNAME] 
			,A.[SORT_ORDER]
			,A.[PARENT_ID] 
			,A.[SUPPLIER_TYPE] 
			,B.[SUPPLIER_TYPE_NAME] 
	  FROM	[FLCR].[SUPPLIER] A
	 INNER JOIN [FLCR].[SUPPLIER_TYPE] B
		ON	A.[SUPPLIER_TYPE] = B.[SUPPLIER_TYPE]
     WHERE	A.[SUPPLIER_ID] = COALESCE(@SUPPLIER_ID,A.[SUPPLIER_ID])
	   AND	A.[ACTIVE_FLG] = COALESCE(@ACTIVE_FLG,A.[ACTIVE_FLG])
	   AND	A.[BUILTIN] = COALESCE(@BUILTIN,A.[BUILTIN])
	   AND	A.[SUPPLIER_TYPE] = COALESCE(@SUPPLIER_TYPE,A.[SUPPLIER_TYPE])
	   AND	A.[DOMAIN_ID]  = COALESCE(@DOMAIN_ID,A.[DOMAIN_ID])

END TRY
BEGIN CATCH
	EXEC [flcr].[utl_getDBError];
END CATCH
